{% extends "buyer/base.html" %}

{% block title %}
    购物车
{% endblock %}

{% block header %}{% endblock %}

{#{% block style %}#}
{#    <script src="/static/store/vendor/bootstrap/js/bootstrap.min.js"></script>#}
{#{% endblock %}#}
{% block order %}
    <div class="sub_page_name fl">|&nbsp;&nbsp;&nbsp;&nbsp;购物车</div>
{% endblock %}

{% block car %}{% endblock %}

{% block search %}
    <div class="search_con fr">
			<input type="text" class="input_text fl" name="" placeholder="搜索商品">
			<input type="button" class="input_btn fr" name="" value="搜索">
    </div>
{% endblock %}

{% block content %}
    <div class="total_count">全部商品<em>{{ goods_list.count }}</em>件</div>
	<ul class="cart_list_th clearfix">
		<li class="col01">商品名称</li>
		<li class="col02">商品单位</li>
		<li class="col03">商品价格</li>
		<li class="col04">数量</li>
		<li class="col05">小计</li>
		<li class="col06">操作</li>
	</ul>
    <form method="post">
    {% csrf_token %}
    {% for goods in goods_list %}
	<ul class="cart_list_td clearfix">
		<li class="col01"><input type="checkbox" class="goods_check" name="goods_{{ goods.id }}" value="{{ goods.id }}" checked></li>
		<li class="col02"><img src="/static/{{ goods.goods_picture }}"></li>
		<li class="col03">{{ goods.goods_name }}<br><em>{{ goods.goods_price }}元/500g</em></li>
		<li class="col04">500g</li>
        <li class="col05"><em class="price">{{ goods.goods_price }}</em>元</li>
		<li class="col06">
			<div class="num_add">
				<a href="javascript:;" onclick="changecount('add')" class="add fl">+</a>
				<input type="text" class="num_show fl" value="{{ goods.goods_number }}">
				<a href="javascript:;" onclick="changecount('minus')" class="minus fl">-</a>
			</div>
		</li>
        <li class="col07"><em class="each_total">{{ goods.goods_total }}</em>元</li>
		<li class="col08"><a href="/Buyer/del_cart/?cart_id={{ goods.id }}">删除</a></li>
	</ul>
    {% endfor %}
	<ul class="settlements">
		<li class="col01"><input id="allBox" type="checkbox" name="" checked=""></li>
		<li class="col02">全选</li>
		<li class="col03">合计(不含运费)：<span>¥</span><em id="total"></em><br>共计<b>{{ goods_list.count }}</b>件商品</li>
		<li class="col04"><input style="width: 80px;height: 50px;background-color: red;border: 0px;color:honeydew;font-size: 18px;border-radius: 5%" type="submit" value="去结算"></li>
	</ul>
    </form>
{% endblock %}
{% block script %}
    <script src="/static/buyer/js/jquery-1.12.4.min.js"></script>
    <script>
        $("#allBox").click(
            function () {
                {#console.log(this.checked)#} //true;false
                if(this.checked){
                    $(".goods_check").prop("checked",true) //prop设置或返回元素的属性和值
                }else {
                    $(".goods_check").prop("checked",false)
                }
            }
        );
        // 当全选之后取消某一商品的勾选，全选的勾选也得去掉
        $(".goods_check").each(
            function () {
                $(this).click(
                    function () {
                        if(!this.checked){
                            $("#allBox").prop("checked",false)
                        }
                    }
                )
            }
        );

        function changecount(sign) {

        }
    </script>
{% endblock %}